//
//  ICatalogs.m
//  XRmenu
//
//  Created by yangxh on 11-3-26.
//  Copyright 2011 E0571. All rights reserved.
//

#import "ICatalogs.h"


@implementation ICatalogs

@synthesize catalogsId;
@synthesize checkInTime;
@synthesize comment;
@synthesize depth;
@synthesize dishCount;
@synthesize globalPath;
@synthesize Id;
@synthesize name;
@synthesize orderNo;
@synthesize parentId;
@synthesize status;
@synthesize type;

//=========================================================== 
// - (id)init
//
//=========================================================== 
- (id)init
{
	return [self initWithCatalogsId:nil checkInTime:nil comment:nil depth:0 dishCount:0 globalPath:nil Id:0 name:nil orderNo:0 parentId:nil status:0 type:0];
}


//=========================================================== 
// - (id)initWith:
//
//=========================================================== 
- (id)initWithCatalogsId:(NSString*)aCatalogsId checkInTime:(NSDate*)aCheckInTime comment:(NSString*)aComment depth:(NSInteger)aDepth dishCount:(NSInteger)aDishCount globalPath:(NSString*)aGlobalPath Id:(NSInteger)anId name:(NSString*)aName orderNo:(NSInteger)anOrderNo parentId:(NSString*)aParentId status:(NSInteger)aStatus type:(NSInteger)aType 
{
    self = [super init];
    if (self) {
        self.catalogsId = aCatalogsId;
        self.checkInTime = aCheckInTime;
        self.comment = aComment;
        self.depth = aDepth;
        self.dishCount = aDishCount;
        self.globalPath = aGlobalPath;
        self.Id = anId;
        self.name = aName;
        self.orderNo = anOrderNo;
        self.parentId = aParentId;
        self.status = aStatus;
        self.type = aType;
    }
    return self;
}


//=========================================================== 
// + (id)objectWith:
//
//=========================================================== 
+ (id)objectWithCatalogsId:(NSString*)aCatalogsId checkInTime:(NSDate*)aCheckInTime comment:(NSString*)aComment depth:(NSInteger)aDepth dishCount:(NSInteger)aDishCount globalPath:(NSString*)aGlobalPath Id:(NSInteger)anId name:(NSString*)aName orderNo:(NSInteger)anOrderNo parentId:(NSString*)aParentId status:(NSInteger)aStatus type:(NSInteger)aType  
{
    id result = [[[self class] alloc] initWithCatalogsId:aCatalogsId checkInTime:aCheckInTime comment:aComment depth:aDepth dishCount:aDishCount globalPath:aGlobalPath Id:anId name:aName orderNo:anOrderNo parentId:aParentId status:aStatus type:aType];
	
    return [result autorelease];
}

//=========================================================== 
// - (NSArray *)keyPaths
//
//=========================================================== 
- (NSArray *)keyPaths
{
    NSArray *result = [NSArray arrayWithObjects:
					   @"catalogsId",
					   @"checkInTime",
					   @"comment",
					   @"depth",
					   @"dishCount",
					   @"globalPath",
					   @"Id",
					   @"name",
					   @"orderNo",
					   @"parentId",
					   @"status",
					   @"type",
					   nil];
	
    return result;
}


//=========================================================== 
// - (NSString *)descriptionForKeyPaths
//
//=========================================================== 
- (NSString *)descriptionForKeyPaths 
{
    NSMutableString *desc = [NSMutableString string];
    NSEnumerator *e = [[self keyPaths] objectEnumerator];
    NSString *thisKey;
    [desc appendString:@"\n\n"];
	
    while ((thisKey = [e nextObject])) {
        [desc appendFormat: @"%@: %@\n", thisKey, [self valueForKey:thisKey]];
    }
	
    return [NSString stringWithString:desc];
}

- (NSString *)description
{
	return [self descriptionForKeyPaths];
}

//=========================================================== 
// dealloc
//=========================================================== 
- (void)dealloc
{
    [catalogsId release];
    catalogsId = nil;
    [checkInTime release];
    checkInTime = nil;
    [comment release];
    comment = nil;
    [globalPath release];
    globalPath = nil;
    [name release];
    name = nil;
    [parentId release];
    parentId = nil;
	
    [super dealloc];
}

+ (ICatalogs *)iCatalogsByParse:(NSDictionary *)info
{
	ICatalogs *catalog = [ICatalogs objectWithCatalogsId:dictObject(info,@"CatalogsId")
											 checkInTime:[NSDate date]
												 comment:dictObject(info,@"Comment")
												   depth:dictInt(info,@"Depth")
											   dishCount:dictInt(info,@"DishCount")
											  globalPath:dictObject(info,@"GlobalPath")
													  Id:dictInt(info,@"ID")
													name:dictObject(info,@"Name")
												 orderNo:dictInt(info,@"OrderNo")
												parentId:dictObject(info,@"ParentId")
												  status:dictInt(info,@"Status")
													type:dictInt(info,@"Type")];
	return catalog;
}

@end
